package com.wingsboat;

/**
 * @author wangzhong
 * @description: TODO
 * @date 2024/7/23 12:16
 */
public class Test19 {
    public static void main(String[] args){
        String input = "11111";
        input = input.toLowerCase();
        int[] pre = new int[input.length()];
        for(int i=0;i<input.length();i++){
            if(i==0){
                if(input.charAt(i)>='a' && input.charAt(i)<='z'){
                    pre[i] = 1;
                }
            }else{
                if(input.charAt(i)>='a' && input.charAt(i)<='z'){
                    pre[i] = 1+pre[i-1];
                }else{
                    pre[i] = pre[i-1];
                }
            }
        }
        int maxLength = -1;
        for(int r=0;r<input.length();r++){
            for(int l=0; l<=r;l++ ){
                if(check(l,r,pre)){
                    maxLength = Math.max(maxLength,r-l+1);
                }
            }
        }
        System.out.println(maxLength);
    }

    public static boolean check(int l,int r,int[] pre){
        if(l==0){
            if(pre[r]==1) return true;
        }else{
            if(pre[r]-pre[l-1] == 1) return true;
        }
        return false;
    }
}
